package org.leetcode.middle.leetcode122;

public class Solution
{


    public int maxProfit2(int[] prices) {
        int maxProfit =0;
        int n = prices.length;

        for (int i = 1; i <n; i++) {
            int todayProfit = prices[i]-prices[i-1];
            maxProfit=maxProfit+Math.max(0,todayProfit);
        }
        return maxProfit;
    }
    public int maxProfit(int[] prices) {
        int maxProfit = 0;

        for (int i = 1; i <prices.length; i++) {
            maxProfit=maxProfit+Math.max(prices[i]-prices[i-1],0);
        }

        return maxProfit;

    }
}
